1408. 数组中的字符串匹配
为保证权益,题目请参考 1408. 数组中的字符串匹配(From LeetCode).
解决方案1
Python
python
# 1408. 数组中的字符串匹配
# https://leetcode.cn/problems/string-matching-in-an-array/
from typing import List
class Solution:
def stringMatching(self, words: List[str]) -> List[str]:
ans = []
for word in words:
for word2 in words:
if word != word2 and word in word2:
ans.append(word)
break
return ans
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15